package com.jiuyun.auth.dao.impl;

import com.jiuyun.auth.dao.UserDao;
import com.jiuyun.auth.entity.User;
import com.jiuyun.auth.util.AliPool;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import javax.naming.Name;
import java.beans.beancontext.BeanContext;
import java.sql.Connection;
import java.sql.SQLException;


public class UserDaoImpl implements UserDao {
    QueryRunner runner = new QueryRunner();
    @Override
    public User login(String uname, String upass) throws SQLException {
        String sql = "select * from user where uname=? and upass=? ";
        Connection conn = AliPool.getConn();
        User user = runner.query(conn,sql,new BeanHandler<User>(User.class),uname,upass);
        conn.close();

        return user;
    }
}
